<template>
  <el-dropdown
    trigger="click"
    class='international'
    @command="handleSetLanguage"
  >
    <div>
      <el-tooltip
        effect="dark"
        :content="$t('navbar.lang')"
        placement="bottom"
      >
        <svg-icon
          class-name='international-icon'
          icon-class="language"
        />
      </el-tooltip>
    </div>
    <el-dropdown-menu slot="dropdown">
      <!-- <el-dropdown-item
        command="zh"
        :disabled="language==='zh'"
      >中文</el-dropdown-item>
      <el-dropdown-item
        command="en"
        :disabled="language==='en'"
      >English</el-dropdown-item> -->
      <el-dropdown-item
        command="zh"
        :disabled="'zh'=== $i18n.locale "
      >中文</el-dropdown-item>
      <el-dropdown-item
        command="en"
        :disabled="'en'=== $i18n.locale "
      >en</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie'
export default {
  name: 'langSelect',
  computed: {
    // language () {
    //   return this.$store.getters.language
    // }
  },
  methods: {
    handleSetLanguage (lang) {
      Cookies.set('language', lang) // 切换多语言
      this.$i18n.locale = lang // 设置给本地的i18n插件
      this.$message.success('切换多语言成功')
      // this.$i18n.locale = lang
      // this.$store.dispatch('setLanguage', lang)
      // this.$message({
      //   message: 'switch language success',
      //   type: 'success'
      // })
    }
  }
}
</script>

<style scoped>
.international-icon {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  vertical-align: -4px !important;
  margin-right: 10px;
}
</style>
